package com.edu.internship.glabal.exception;

import com.edu.internship.glabal.constants.ICodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * code is far away from bug with the animal protecting
 *
 * @author lishiquan
 * @description
 * @date 2022-07-29
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BusinessException extends RuntimeException {

    private static final long serialVersionUID = -8661950806210020649L;

    private ICodeEnum codeEnum;
    private String msg;

    /**
     * 验证的时候,手动抛该异常
     *
     * @param codeEnum 定义的错误枚举
     */
    public BusinessException(ICodeEnum codeEnum) {
        super(codeEnum.getDesc());
        this.codeEnum = codeEnum;
    }

    /**
     * 验证的时候,手动抛该异常
     *
     * @param codeEnum 定义的错误枚举
     * @param errMsg   错误信息
     */
    public BusinessException(ICodeEnum codeEnum, String errMsg) {
        super(errMsg);
        this.msg = errMsg;
        this.codeEnum = codeEnum;
    }
}
